View Javadoc
1 /* 2 * Angkor Web Framework 3 * 4 * Distributable under LGPL license. 5 * See terms of license at gnu.org. 6 */ 7 package com.tirsen.angkor.widget; 8 9 10 /*** 11 * A ModelProxy acts as the proxy for JavaBean instances which may or may not actually 12 * exist enabling them to be lazily evaluated only when a view actually requests the value 13 * of the JavaBean. Useful when creating views which should be bound to properties of JavaBeans 14 * but the view is not yet visible and the JavaBean is not yet instantiated. Also has a lot of 15 * utility methods for creating various models bound to the JavaBean so it may be useful even if 16 * the JavaBean actually exists. For this reason the name <code>ModelProxy</code> may be a little bit 17 * inaccurate, maybe <code>JavaBeanModel</code> may be better. 18 * 19 * <!-- $Id: ModelProxy.java,v 1.3 2002/10/09 21:37:37 tirsen Exp $ --> 20 * 21 * @author $Author: tirsen $ 22 * @version $Revision: 1.3 $ 23 */ 24 public class ModelProxy 25 { 26 private Object valueObject; 27 private ValueModel model; 28 private Class objectClass; 29 30 public ModelProxy(Class objectClass) 31 { 32 this.objectClass = objectClass; 33 } 34 35 public ModelProxy(ValueModel model) 36 { 37 this.model = model; 38 } 39 40 public void setValueObject(Object valueObject) 41 { 42 this.valueObject = valueObject; 43 } 44 45 public Object getObject() 46 { 47 Object object = valueObject; 48 if (object == null && model != null) object = model.getValue(); 49 return object; 50 } 51 52 public Class getObjectClass() 53 { 54 Class klass = objectClass; 55 if (klass == null && valueObject != null) klass = valueObject.getClass(); 56 if (klass == null && model != null) klass = model.getValueClass(); 57 return klass; 58 } 59 60 public ValueModel getProperty(String property) 61 { 62 return new PropertyValueModel(this, property); 63 } 64 65 public ModelProxy getPropertyProxy(String property) 66 { 67 return new ModelProxy(getProperty(property)); 68 } 69 }

This page was automatically generated by Maven